package nc.ui.medpub.bd.hf00100503;

import java.util.Collection;

import nc.bs.framework.common.NCLocator;
import nc.itf.uap.IUAPQueryBS;
import nc.ui.trade.adapter.CtrlDelegatorAdapter;
import nc.ui.trade.bsdelegate.BusinessDelegator;
import nc.ui.trade.controller.IControllerBase;
import nc.vo.medpub.bd.hf00100503.MedConvertVO;
import nc.vo.medpub.bd.hf00100503.MedInvbasdocVO;
import nc.vo.pub.AggregatedValueObject;

public class MedInvBasDelegatorAdapter extends CtrlDelegatorAdapter{

	public MedInvBasDelegatorAdapter(BusinessDelegator delegator, IControllerBase uiCtrl) {
		super(delegator, uiCtrl);
	} 
	@SuppressWarnings("unchecked")
	public void checkAndGetBodyVO(AggregatedValueObject billVO) throws Exception {
		if (billVO == null)
			return;
			
		MedInvbasdocVO headVO = (MedInvbasdocVO) billVO.getParentVO();
		MedConvertVO[] vos =(MedConvertVO[])billVO.getChildrenVO();

		if (vos == null)
		{
			IUAPQueryBS service = NCLocator.getInstance().lookup(IUAPQueryBS.class);
			Collection<MedConvertVO> c = service.retrieveByClause(MedConvertVO.class, "pk_medinvbasdoc = '"+headVO.getPrimaryKey()+"'");
			billVO.setChildrenVO(c.toArray(new MedConvertVO[0]));
		}

	}
}
